import 'package:flutter/material.dart';
import 'package:tree_hole/letters/LetterPage.dart';
import 'package:tree_hole/res/LetterPaperData.dart';
import 'LetterPage.dart';

//选择信纸界面
class LetterPaperPage extends StatelessWidget{
  final String token;
  LetterPaperPage(this.token);
  Widget build(BuildContext context){
    return Scaffold(
      appBar: new AppBar(
        title: new Text('选择信纸',style:TextStyle(color: Colors.black)),
        backgroundColor: Colors.white70,
        leading: IconButton(
          icon:Icon(Icons.arrow_back,color: Colors.black),
          onPressed: () {Navigator.pop(context);},
        ),
      ),
      body: ListView(
        scrollDirection: Axis.horizontal,
        children: LetterPaperData.map((value){
          return Container(
            width: 500,
            decoration: BoxDecoration(
                color: Colors.amber[50]
            ),
            child: Column(
              children:<Widget> [
                Expanded(
                    flex: 1,
                    child: SizedBox()),
                Expanded(
                    flex:8,
                    child:AspectRatio(
                      aspectRatio: 9/16,
                      child:Image.asset(value["paper"],fit: BoxFit.cover,) ,
                    )
                ),
                Expanded(
                    flex: 1,
                    child: SizedBox()),
                Expanded(
                    flex: 3,
                    child: ListTile(
                      leading:IconButton(
                        icon: Icon(Icons.arrow_forward_ios,color: Colors.black,),
                        onPressed: (){
                          Navigator.of(context).push(
                              MaterialPageRoute(builder: (context){
                                return LetterPage(this.token,value["paper"]);
                              },)
                          );
                        },
                      ),
                      title: Text(value["name"]),
                      subtitle: Text(value["note"]),
                    ))
              ],
            ),
          );
        }).toList(),
      ),
    );
  }
}